package com.mzmarket.market.module.mapper;

import com.mzmarket.market.module.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

        // 根据ID查询（逻辑未删除）
        @Select("select * from user where phone =#{phone} and is_deleted = 0")
            User getByPhone(@Param("phone") String phone);

        // 根据ID查询（包含已删除）
        @Select("select * from user where phone =#{phone}")
            User extractByPhone(@Param("phone") String phone);

        // 插入
        int insert(@Param("user") User user);

        // 更新
        int update(@Param("user") User user);

        // 逻辑删除
        @Update("update user set is_deleted = 1, update_time=#{time} where phone = #{phone} limit 1 ")
        int delete(@Param("phone") String phone, @Param("time") Integer time);
        }